home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1997 May / PC Plus Super CD Issue 127 (May 1997).iso / delphi1 / lesson3 / editor2 / ioprocs.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1996-01-04  |  1.1 KB  |  34 lines

  1. unit Ioprocs;
  2.  
  3. interface
  4. (* Any procedures and functions which you want to be visible
  5.   to other programs using this unit must be declared in the
  6.   interface section. If you comment out the declartion between
  7.   curly brackets {} and try to run the Edit2
  8.   program, the compiler will report an error. *)
  9.  
  10. function ThisFileExists(FileName: String): Boolean;
  11.  
  12. implementation
  13. function ThisFileExists(FileName: String): Boolean;
  14. { Returns True if the file exists. Otherwise
  15.   it returns False. You can get the same functionality
  16.   from the FileExists function in the standard SysUtils
  17.   unit. }
  18.  var
  19.   F: file;
  20. begin
  21.   {$I-}                    { turn off IO checking         }
  22.   AssignFile(F, FileName); { Assign the file name         }
  23.   FileMode := 0;         { Set file access to read only }
  24.   Reset(F);                { Try to open the file         }
  25.   CloseFile(F);
  26.   {$I+}                    { Turn IO checking on again    }
  27.                            { Test IOResult returned       }
  28.   ThisFileExists := (IOResult = 0) and (FileName <> '');
  29. end;  { FileExists }
  30.  
  31.  
  32.  
  33. end.
  34.